/**
 * Created by Administrator on 2018-07-28.
 */
/**
 * Created by Administrator on 2018/4/26.
 */
define(function (require,exports,module) {
    var sTpl = require("./processKanban.html");
     require("./thisback.css")
    require("../../../lib/fullcalendar/moment.min.js");
    var  component =  require("../table/flightDynamic.js");
    var DEFINE_STATUS = require("../../util/status.js");
    var VueComponent = Vue.extend({
        components:{'enter':component},
        template: sTpl,
        methods:{

            queryAll:function () {
                var $this = this;
                axios.get(basepath+"/api/flightPlane/findFlightDynamicPlaneNoPage?").then(function(response){
                    $this.dataArray = response.data;
                })
            }
        },
        mounted:function() {
           this.queryAll();
        },
        watch:{
            dataArray:function (nv) {
                this.safeguard =nv.filter(function (val) {
                    if(val.processStatus>=DEFINE_STATUS.statusNum.ENSURE_START&&val.processStatus<=DEFINE_STATUS.statusNum.ENSURE_END){
                        return val;
                    }
                });
                this.expectedTakeOff=nv.filter(function (val) {
                   if(val.importOrExport=="出港"&&val.processStatus==DEFINE_STATUS.statusNum.EXPECTED_TO_FLY){
                       return val;
                   }
                });
                this.flying=nv.filter(function (val) {
                    if(val.importOrExport=="出港"&&val.processStatus==DEFINE_STATUS.statusNum.TAKE_OFF){
                        return val;
                    }
                });
                this.abnormals=nv.filter(function (val) {
                    if(val.isDelay=="延误"){
                        return val;
                    }
                });
                this.expectedArrive=nv.filter(function (val) {
                    if(val.importOrExport=="进港"&&(val.processStatus==DEFINE_STATUS.statusNum.EXPECTED_TO_FALL||val.processStatus==DEFINE_STATUS.statusNum.NEAR_SPACE||val.processStatus==DEFINE_STATUS.statusNum.TAKE_OFF)){
                        return val;
                    }
                });

            }
        },
        data:function(){
            var $this = this;
            var interval = setInterval(function(){
                $this.time=moment().format("HH:mm:ss");
                var cd =  new Date();
                $this.date = moment().format("YYYY-MM-DD")
                    + ' ' +['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'][cd.getDay()];
            }, 1000);

            return {
                dataArray:[],
                DEFINE_STATUS:DEFINE_STATUS,
                expectedTakeOff:[],
                safeguard:[],
                flying:[],
                expectedArrive:[],
                abnormals:[],
                childrenData:{
                    dataRefresh:function (data) {
                        $this.dataArray = data;
                    }
                },
                time:"",
                date:""
            }
        },
        created:function (){

        }
    });

    module.exports = VueComponent;
    return VueComponent;
})
